Do not wait for memory teardown when live migrate
authorMiroslav Rezanina <mrezanin@redhat.com>
Thu, 28 Oct 2010 10:40:32 +0000 (11:40 +0100)
committerMiroslav Rezanina <mrezanin@redhat.com>
Thu, 28 Oct 2010 10:40:32 +0000 (11:40 +0100)
When trying to live migrate guest with great memory (e.g. 20 GB),
there's delay caused by destroying source copy of domain.  To speed up
this process we can close socket before starting guest destroy, as
source guest is not running anymore.

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/python/xen/xend/XendCheckpoint.py
tools/python/xen/xend/XendDomain.py

index 4c68fb38af4f0a17aa330443756a4a3c9f4eb6d3..fa09757a4881e43c2c8b9da9a49c4b94d363d971 100644 (file)
@@ -65,7 +65,7 @@ def insert_after(list, pred, value):
     return
 
 
-def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1):
+def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1,sock=None):
     from xen.xend import XendDomain
 
     try:
@@ -162,6 +162,13 @@ def save(fd, dominfo, network, live, dst, checkpoint=False, node=-1):
         if checkpoint:
             dominfo.resumeDomain()
         else:
+            if live and sock != None:
+                try:
+                    sock.shutdown(2)
+                except:
+                    pass
+                sock.close()
+
             dominfo.destroy()
             dominfo.testDeviceComplete()
         try:
index 71aae2a58e4f6c044d7469d3d7adec470b38f79d..1d4da8ffbcce800d60b20ebe0b069594854a20ed 100644 (file)
@@ -1412,7 +1412,7 @@ class XendDomain:
         try:
             try:
                 XendCheckpoint.save(p2cwrite, dominfo, True, live, dst,
-                                    node=node)
+                                    node=node,sock=sock)
             except Exception, ex:
                 m_dsterr = None
                 try:
@@ -1436,15 +1436,16 @@ class XendDomain:
                     raise XendError("%s (from %s)" % (m_dsterr.group(2), dst))
                 raise
         finally:
-            try:
-                sock.shutdown(2)
-            except:
-                # Probably the socket is already disconnected by sock.close
-                # in the destination side.
-                # Ignore the exception because it has nothing to do with
-                # an exception of XendCheckpoint.save.
-                pass
-            sock.close()
+            if not live:
+                try:
+                    sock.shutdown(2)
+                except:
+                    # Probably the socket is already disconnected by sock.close
+                    # in the destination side.
+                    # Ignore the exception because it has nothing to do with
+                    # an exception of XendCheckpoint.save.
+                    pass
+                sock.close()
 
         os.close(p2cread)
         os.close(p2cwrite)
@@ -1469,7 +1470,7 @@ class XendDomain:
         try:
             try:
                 XendCheckpoint.save(sock.fileno(), dominfo, True, live,
-                                    dst, node=node)
+                                    dst, node=node,sock=sock)
             except Exception, ex:
                 m_dsterr = None
                 try:
@@ -1493,15 +1494,16 @@ class XendDomain:
                     raise XendError("%s (from %s)" % (m_dsterr.group(2), dst))
                 raise
         finally:
-            try:
-                sock.shutdown(2)
-            except:
-                # Probably the socket is already disconnected by sock.close
-                # in the destination side.
-                # Ignore the exception because it has nothing to do with
-                # an exception of XendCheckpoint.save.
-                pass
-            sock.close()
+            if not live:
+                try:
+                    sock.shutdown(2)
+                except:
+                    # Probably the socket is already disconnected by sock.close
+                    # in the destination side.
+                    # Ignore the exception because it has nothing to do with
+                    # an exception of XendCheckpoint.save.
+                    pass
+                sock.close()
 
     def domain_save(self, domid, dst, checkpoint=False):
         """Start saving a domain to file.